package com.zkx.fssb.controller.server;


import com.zkx.fssb.domain.dto.AddressDto;
import com.zkx.fssb.domain.po.Address;
import com.zkx.fssb.result.Result;
import com.zkx.fssb.service.AddressService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@Slf4j
@RestController("serverAddressController")
@RequestMapping("/server/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    @GetMapping("/{userId}")
    private Result<List<Address>> getByUserId(Integer userId){

        List<Address> addressList = addressService.getByUserId(userId);

        return Result.success(addressList);

    }

    /**
     * 新建用户地址
     * @param addressDto
     * @return
     */
    @PostMapping
    public Result saveAddress(@RequestBody AddressDto addressDto){

        addressService.customSaveAddress(addressDto);
        return Result.success();
    }





}
